<route lang="json5">
{
  style: {
    navigationBarTitleText: '',
  },
}
</route>

<template>
  <view>
    <web-view
      :src="src"
      @load="onWebviewLoad"
      @error="onWebViewError"
    ></web-view>
  </view>
</template>

<script setup>
const src = ref('')
onLoad((options) => {
  const { title, url } = options
  if (title) {
    uni.setNavigationBarTitle({
      title,
    })
  }
  if (url) {
    const u = decodeURIComponent(url)
    src.value = u
  }
  uni.showLoading({
    title: '加载中...',
    mask: true,
  })
})

const onWebviewLoad = () => {
  uni.hideLoading()
}

const onWebViewError = () => {
  uni.hideLoading()
  uni.showToast({
    title: '加载失败',
    icon: 'error',
  })
}
</script>
